package com.jp.knowledge.adapter;

import android.content.Context;
import android.support.annotation.NonNull;

import com.jp.knowledge.R;
import com.jp.knowledge.model.ProductUIMenuModel;
import com.jp.knowledge.my.base.RecycleVAdapter;
import com.jp.knowledge.my.base.RecycleVHolder;

import java.util.List;

/**
 * Created by 528787067@qq.com on 2017/5/11.
 */

public class ProductInterfaceRightMenuAdapter extends RecycleVAdapter<ProductUIMenuModel> {

    private int selectedPosition;

    public ProductInterfaceRightMenuAdapter(Context context, @NonNull List<ProductUIMenuModel> list) {
        super(context, list);
        selectedPosition = 0;
    }

    public int getSelectedPosition() {
        return selectedPosition;
    }

    public void setSelectedPosition(int selectedPosition) {
        this.selectedPosition = selectedPosition;
    }

    @Override
    public int getLayoutId(int viewType) {
        return R.layout.item_product_interface_rigth_menu;
    }

    @Override
    public void onBind(RecycleVHolder holder, int position) {
        ProductUIMenuModel data = getData(position);
        if(position == selectedPosition)
            holder.getConvertView().setBackgroundColor(mContext.getResources().getColor(R.color.bg_color_layout));
        else
            holder.getConvertView().setBackgroundColor(mContext.getResources().getColor(R.color.translate));
        holder.setTextView(R.id.right_item_tv, data.getName());
    }
}
